package file;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

public class Exercise {
    public static void main(String[] args) throws IOException {
      /* File file=new File("demo");
        String name =file.getName();
        System.out.println(name);

        long a=file.length();
        System.out.println(a);
        boolean a1=file.isHidden();
        boolean a2=file.canRead();
        boolean a3=file.canWrite();
        System.out.println(a1);
        System.out.println(a2);
        System.out.println(a3);





        File file1=new File("demo");
        if (file1.exists()){
            System.out.println("文件已存在");
        }else{
            file1.createNewFile();
            System.out.println("已创建");

        }

        File aa=new File("./dem");
        if (aa.exists()){
            System.out.println("一直存在");
        }else{
            aa.mkdirs();
            System.out.println("已创建");
        }




        File file2=new File("./dem");
        if (file2.exists()){
            file2.delete();
            System.out.println("已删除");
        }else{
            System.out.println("不存在");
        }



        File dir=new File(".");

        if(dir.isDirectory()) {
            File[] subs = dir.listFiles();
            System.out.println(subs.length);

            for (File sub : subs) {
                System.out.println(sub.getName());
            }
        }*/



        /*File file3=new File(".");
        if (file3.isDirectory()){
            FileFilter filter1=new FileFilter() {
                @Override
                public boolean accept(File file3) {
                    String name =file3.getName();
                    return name.endsWith(".txt");
                }
            };
            File[] subs=file3.listFiles(filter1);
            for (File cc:subs){
                System.out.println(cc.getName());
            }

        }


        File qq=new File(".");
        if (qq.isDirectory()) {
            FileFilter tt = new FileFilter() {
                @Override
                public boolean accept(File qq) {
                    String name = qq.getName();
                    return name.endsWith(".txt");
                }
            };


            File[] ee = qq.listFiles(tt);
            for (File yy : ee) {
                System.out.println(yy.getName());
            }
        }*/




        File ddar=new File(".");
        if (ddar.isDirectory()){
            File[] ssu=ddar.listFiles(file ->file.getName().endsWith(".txt"));
            for (File mm:ssu){
                System.out.println(mm.getName());
        }


        }






















    }
}
